package com.chenjun.core.dao.generator.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.chenjun.core.dao.generator.entity.SysGroup;
import com.chenjun.core.dao.generator.entity.SysGroupExample;

public interface SysGroupMapper {
    @Delete({
        "delete from sys_group",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into sys_group (id, code, ",
        "name, status, create_time, ",
        "update_time, operator, ",
        "note, parent_id, ",
        "parent_ids, sort_index, ",
        "level)",
        "values (#{id,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP}, #{operator,jdbcType=INTEGER}, ",
        "#{note,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, ",
        "#{parentIds,jdbcType=VARCHAR}, #{sortIndex,jdbcType=INTEGER}, ",
        "#{level,jdbcType=VARCHAR})"
    })
    int insert(SysGroup record);

    int insertSelective(SysGroup record);

    List<SysGroup> selectByExample(SysGroupExample example);

    @Select({
        "select",
        "id, code, name, status, create_time, update_time, operator, note, parent_id, ",
        "parent_ids, sort_index, level",
        "from sys_group",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    SysGroup selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(SysGroup record);

    @Update({
        "update sys_group",
        "set code = #{code,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "operator = #{operator,jdbcType=INTEGER},",
          "note = #{note,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=VARCHAR},",
          "parent_ids = #{parentIds,jdbcType=VARCHAR},",
          "sort_index = #{sortIndex,jdbcType=INTEGER},",
          "level = #{level,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(SysGroup record);
}